package cn.iocoder.yudao.module.javainfo.dal.mysql.productsort;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.javainfo.controller.admin.productsort.vo.ProductSortListReqVO;
import cn.iocoder.yudao.module.javainfo.dal.dataobject.productsort.ProductSortDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface ProductSortMapper extends BaseMapperX<ProductSortDO> {

    default ProductSortDO selectByParentIdAndName(Long parentId, String name) {
        return selectOne(new LambdaQueryWrapperX<ProductSortDO>()
                .eq(ProductSortDO::getParentId, parentId)
                .eq(ProductSortDO::getName, name));
    }

    default Long selectCountByParentId(Long parentId) {
        return selectCount(ProductSortDO::getParentId, parentId);
    }

    default List<ProductSortDO> selectList(ProductSortListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProductSortDO>()
                .likeIfPresent(ProductSortDO::getName, reqVO.getName())
                .eqIfPresent(ProductSortDO::getStatus, reqVO.getStatus()));
    }

    default List<ProductSortDO> selectByIds(List<Long> ids) {
        return selectBatchIds(ids);
    }

    default void deleteByIds(List<Long> ids) {
        deleteBatchIds(ids);
    }
}

